var webpackConfig = require('./webpack.config.js'),
    gulp = require('gulp'),
    webpack = require("webpack"),
    browserSync = require('browser-sync').create();// 静态服务器

var myConfig = Object.create(webpackConfig),
    reload      = browserSync.reload;

var path = {
    baseDir: './',
    vue: 'resource/js/**/*.vue',
    // js: 'resource/view/game/Chameleon/**/*.js',
    js: 'resource/view/game/Chameleon/js/*.js',
    html:'resource/view/*.html'
};
gulp.task('default', ['webpack', 'serve', 'watch']);

//gulp.task('jshint', function() {
//    return gulp.src('src/app/**/*.js')
//        .pipe(jshint())
//        .pipe(jshint.reporter('jshint-stylish'));
//});

// Static server
gulp.task('serve', function() {
    browserSync.init({
        server: {
            baseDir: path.baseDir
        }
    });
});
gulp.task('watch', function () {
    gulp.watch([
        path.vue,
        path.js,
        path.html,
    ], ['webpack', reload], reload);
});
gulp.task("webpack", function(callback) {
    webpack(myConfig, function(err, stats) {
        callback();
    });
});
gulp.task('watchVue',function(){
    gulp.watch(['resource/js/**/*.vue','resource/js/**/*.js'], ['webpack']);
});
